package gutils

import (
	"github.com/google/uuid"
)

func GenUuidV7() string {
	uuidRes, _ := uuid.NewV7()
	return uuidRes.String()
}

// UuidTextToBinary 将文本形式的 UUID 转换为二进制
func UuidTextToBinary(text string) ([]byte, error) {
	id, err := uuid.Parse(text)
	if err != nil {
		return nil, err
	}
	return id[:], nil
}

// UuidBinaryToText 将二进制形式的 UUID 转换为文本
func UuidBinaryToText(binary []byte) (string, error) {
	id, err := uuid.FromBytes(binary)
	if err != nil {
		return "", err
	}
	return id.String(), nil
}
